package ar.com.photo_admin.service.assembler
import ar.com.photo_admin.domain.*;
import ar.com.photo_admin.service.dto.AlbumDTO;
import ar.com.photo_admin.service.dto.AlbumLightWeightDTO;

class AlbumAssembler extends BaseAssembler {
	
	PhotoAssembler photoAssembler = new PhotoAssembler()
	
	def toBean(album){
		AlbumDTO bean = new AlbumDTO()
		
		bean.id = album.id;
		bean.name = album.name;
		bean.cover = album.coverPhoto != null ? photoAssembler.toBean(album.coverPhoto) : null 
		bean.photos = photoAssembler.toBeans(album.getAlbumPhotos())
		
		return bean;
	}
	
	def toLightWeightBean(album){
		AlbumLightWeightDTO bean = new AlbumLightWeightDTO()
		
		bean.id = album.id;
		bean.name = album.name;
		bean.cover = album.coverPhoto != null ? photoAssembler.toBean(album.coverPhoto) : null
		
		return bean;
	}
}
